* TScanCDEV::DoHit() contains a hard-coded literal string; it should be stored as a resource
* TScanCDEV::ScanDirectory() assumes that the volume being scanned is an HFS volume
* the values of TScanCDEV::kDirectoryRect, TScanCDEV::kFileRect and TScanCDEV::kStatusRect are hard-coded; they should be stored as resources
*/
#ifndef __PACKAGES__
#include <Packages.h>
#endif
#ifndef __TOOLUTILS__
#include <ToolUtils.h>
#endif
#ifndef __USCANCDEV__
#include "UScanCDEV.h"
#endif
const Rect TScanCDEV::kDirectoryRect = {17, 148, 31, 300}; // !!!
const Rect TScanCDEV::kFileRect = {30, 148, 44, 300}; // !!!
const Rect TScanCDEV::kStatusRect = {4, 148, 18, 300}; // !!!
void TScanCDEV::DoHit(short item, EventRecord *, long *cdevValue) {
if (item == ok) {
SetCursor(watchCursor);
ShowStatus("\pScanning"); // !!!
ScanVolume();
EraseRect(&kDirectoryRect); // EraseRect() moves/purges memory, but these fields are static (stack-based), so this call should be safe
EraseRect(&kFileRect);
DoUpdate(cdevValue);
}
}
void TScanCDEV::ScanDirectory(long directory) {
const short kDirectoryBit = 1 << 4;
short dirIndex = 1;
while (fCatalogInfo.hFileInfo.ioFDirIndex = dirIndex++, // set the index field of the parameter block; increment our directory index (this is not part of the condition)
fCatalogInfo.hFileInfo.ioDirID = directory, // set the directory field of the parameter block (this is not part of the condition either)
!PBGetCatInfo(&fCatalogInfo, false)) // get the directory’s catalog entry (this is the condition)
if (fCatalogInfo.hFileInfo.ioFlAttrib & kDirectoryBit) { // check to see if it is a directory
DoDirectory(fCatalogInfo);
ScanDirectory(fCatalogInfo.hFileInfo.ioDirID); // recursively scan the contents of the current directory
}
else
DoFile(fCatalogInfo);
}
void TScanCDEV::ScanVolume() {
fCatalogInfo.hFileInfo.ioVRefNum = 0; // scan the startup volume
fCatalogInfo.hFileInfo.ioNamePtr = fDirEntryName; // give the file system someplace to put the entry’s name